package JBANK;
/**
 * Teller Class | SourceCode = Teller.java 
 * @Author Rudy Matos
 * @Version 1.0 of JBANK
 * @Date 07/21/07
 */

import java.util.ArrayList;

//Declaring a Teller Class

public class Teller{


	public static void main(String [] args)throws Exception{

		ArrayList <Customer> listCustomer = new ArrayList <Customer> ();	
		ArrayList <Account> listAccount = new ArrayList <Account>();

		boolean salir = false;

		System.out.println(Bank.BANK_NAME+"\t"+Bank.BANK_ADDRESS+"\t"+"Actually MaxNumberOfCustomer.: "+Bank.MAX_NUMBER_OF_CUSTOMER);
		Utils.spaces_lines();

		do{

			System.out.println("Welcome Teller. What do you want to do now?");
			System.out.println("C - Create a Customer"+"\n"+"A - Create an Account"+"\n"+"N - Normal Selection"+"\n"+"Q - Quit");

			char response = (char)System.in.read();
			System.in.read();
			System.in.read();

			switch (response){

			case 'n':{

				Customer c1 = new Customer();
				System.out.println("Customer Id.:  "+c1.getCustID());
				System.out.println("Enter Customer Last Name.: ");
				String cLName = Utils.inputString();
				System.out.println("Enter Customer First Name.: ");
				String cFName = Utils.inputString();
				c1.setCustomerName(cFName, cLName);
				listCustomer.add(c1);			

				Utils.lines(3);

				Account a1 = new Account();
				System.out.println("Creating Saving Account... ");
				a1.setID(c1.getCustID()+"S");
				System.out.println("Saving Account Number .: "+a1.getID());

				do{

					System.out.println("Enter the initial Amount for this Saving Account");
					int iValue = Utils.inputNum();

					if (iValue < 200){

						System.out.println("The amount for savings accounts must be greater than $200.00 Pesos");

					}else {

						a1.setBalance(iValue);				
						listAccount.add(a1);

					}

				}while (a1.getBalance() < 200);
				break;

			}//Case 'N' end

			case 'q':{

				salir = true;
				break;

			}

			default :{

				System.err.println("You did not enter any valid value");
				break;

			}						
			}//End Switch

		}while(salir == false); //End 1st Do

		System.out.println("List of Created Customer");

		//Assing Values
		for(int i = 0; i<=listCustomer.size()-1; i++){

			listCustomer.get(i).setAccount(listAccount.get(i));
			System.out.println(listCustomer.get(i).getCustomerName()+"  Balance.: "+listCustomer.get(i).getAccount().getBalance());

		}

		System.out.println("Total of Customer.: "+listCustomer.size());

	}//Main Brace
}
